home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / p1123mz4.zip / SPIKE.CPP < prev    next >
Text File  |  1994-03-02  |  3KB  |  91 lines

  1. //      This program plots
  2. // z=2.0*cos(7.0*sqrt(x*x+y*y))*cos(7.0*sqrt(x*x+y*y))/(1.0+30.0*(x*x+y*y))
  3. // in three dimensions on a Panasonic 1123 printer.
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <math.h>
  8. #include <stdlib.h>
  9. #include <conio.h>
  10. #include <iostream.h>
  11. #include "titillat.h"
  12. #include "plot3d.h"
  13. #include "x1123x3d.h"
  14.  
  15. #ifndef TRUE
  16. #define TRUE -1
  17. #endif
  18. #ifndef FALSE
  19. #define FALSE 0
  20. #endif
  21.  
  22. static int    external_to_plot(double,double);
  23. static double f(double,double);
  24.        int    main(void);
  25. static int    red(double,double);
  26.  
  27. extern unsigned _stklen=0x8000;
  28.  
  29. int main()
  30.     {
  31.       static   int      fatal_error;
  32.       static   double   light_x;
  33.       static   double   light_y;
  34.       static   double   light_z;
  35.       static   double   rotation;
  36.       static   double   tilt;
  37.       static   x1123x3d *x1123x3d_ptr;
  38.  
  39.       fatal_error=FALSE;
  40.       x1123x3d_ptr=new x1123x3d();
  41.       rotation=(double) 0.0;
  42.       tilt=(double) 30.0;
  43.       light_x=(double) 1.0;
  44.       light_y=(double) -1.0;
  45.       light_z=(double) 1.0;
  46.       if (x1123x3d_ptr->prepare_plot(f, // function f(x,y) to be plotted
  47.        -1.0,                            // minimum x
  48.        1.0,                             // maximum x
  49.        -1.0,                            // minimum y
  50.        1.0,                             // maximum y
  51.        external_to_plot,                // don't plot -- always FALSE
  52.        red,                             // highlight -- always FALSE
  53.        120,                             // number of x divisions
  54.        120,                             // number of y divisions
  55.        rotation,                        // rotation in degrees
  56.        tilt,                            // tilt in degrees
  57.        light_x,light_y,light_z))        // vector to light source
  58.         {
  59.           if (x1123x3d_ptr->plot("SPIKE",    // output file name
  60.                               FALSE,         // highlight flagged areas
  61.                               TRUE))         // amuse user while plotting
  62.             cout << "\"COPY /B SPIKE LPT1:\"" << '\n';
  63.         }
  64.       delete x1123x3d_ptr;
  65.       return(fatal_error);
  66.     }
  67.  
  68. static int external_to_plot(
  69.   double x,
  70.   double y)
  71.     {
  72.        return FALSE;
  73.     }
  74.  
  75. static int red(
  76.   double x,
  77.   double y)
  78.     {
  79.        return FALSE;
  80.     }
  81.  
  82. static double f(
  83.   double x,
  84.   double y)
  85.     {
  86.        double t1=x*x+y*y;
  87.        double t2=cos(7.0*sqrt(t1));
  88.        return 2.0*t2*t2/(1.0+30.0*t1);
  89.     }
  90. 
  91.